package controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import pojo.SpareParts;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/spareParts")
public class SparePartsController {
    @RequestMapping("/addSpareParts")
    public String addSpareParts(Model model, HttpServletRequest request, HttpServletResponse response)throws Exception {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        String type=request.getParameter("type");
        double price= Double.parseDouble(request.getParameter("price"));
        String time=request.getParameter("time");

        SpareParts spareParts=new SpareParts(type,price,time);
        model.addAttribute("spareParts",spareParts);

        return "spareParts/sparePartsList";
    }

    @RequestMapping("/sparePartsHome")
    public String sparePartsHome()throws Exception {
        return "spareParts/sparePartsAdd";
    }
}
